<?php

//inculde即可以使用data数据。本页所有的data数据，倾在controller都处理好
include_once("../../../common/module/checkA.php");
include_once("../../../../config.php");
include_once("../controller/detail-list.php");

include_once("module/select_datas.php");
include_once("module/select_category.php");
include_once("module/count.php");

?>




<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>

    <? include_once(ROOT_PATH_ . "/controller/common/module/head.php"); ?>

    <?php include 'module/head.php'; ?>
</head>

<body>

<div id="topbar">
    <?php include ROOT_PATH_ . '/controller/common/module/topbar.php'; ?>
</div>

<div id="container" class="<? echo $system_part ?>">

    <div id="maincontent">

        <div id="sidebar">
            <?php include ROOT_PATH_ . '/controller/common/module/sidebar.php'; ?>
        </div>

        <div id="content">
            <?php $page_title = '产品列表'; ?>
            <?php include ROOT_PATH_ . '/controlbase/module/mod-page-title.php'; ?>

            <? $action="detail-list.php?nav-itemed=product"?>
            <?php include 'module/mod-search.php'; ?>

<!--    <div class="statistic">-->
<!---->
<!--        <button class="layui-btn layui-btn-sm" id="quanxuan"><i class="layui-icon">&#x1005;</i>全选</button>-->
<!--        <button class="layui-btn layui-btn-sm" id="buxuan"><i class="layui-icon">&#xe63f;</i>不选</button>-->
<!--        <button class="layui-btn layui-btn-sm" id="cancle_product">下架选中</button>-->
<!--        <button class="layui-btn layui-btn-sm" id="cancle_product">上架选中</button>-->
<!---->
<!--        <a class="layui-btn layui-btn-sm" href="collect.php?now_extender=--><?php //echo $system_part?><!--"><i class="fa fa-bar-chart-o" aria-hidden="true"></i>  统计</a>-->
<!--        <a class="layui-btn layui-btn-sm" href="detail-add.php?nav-itemed=unit&now_extender=--><?php //echo $system_part?><!--"><i class="layui-icon">&#xe608;</i>  新增</a>-->
<!---->
<!--        <button type="button" class="layui-btn layui-btn-sm" >上架中: --><?// echo $productNumcount ?><!--</button>-->
<!--        <button type="button" class="layui-btn layui-btn-sm" >库存不足: --><?// echo $storageNumcount ?><!--</button>-->
<!---->
<!--        <a class="layui-btn  layui-btn-sm all_qcode" href="erweima_all_list.php?nav-itemed=unit&now_extender=--><?php //echo $system_part?><!--"><i class="layui-icon">&#xe64a;</i>  二维码批量生成</a>-->
<!---->
<!--        <hr/>-->
<!--    </div>-->


<!-- 用$system_part .list_boxes来控制来到确认板块信息显示-->
<div class="list-box">
<div class="list-boxes">
<table class="layui-table">
  <colgroup>
    <col width="60">
<!--    <col width=" ">-->
    <col width=" ">
    <col width="180">
    <col width="100">
    <col width="100">
    <col width="">
    <col width="250">

  </colgroup>
  <thead>
    <tr>
      <th>序号</th>
<!--      <th>图片</th>-->
      <th>名字</th>
      <th>型号</th>
      <th>所属分类</th>
      <th>指导价格</th>
      <th>状态</th>
      <th>操作</th>
    </tr>
  </thead>
  <tbody>

  <?php

    if ($detailnum == 0) {
      echo "<tr><td colspan='6'>暂无数据</td></tr>";
    }

	for ($i = 0; $i < $detailnum; $i++) {
    ?>

      <tr id="item<?echo $detail[$i]['nid']?>" >
<!--          <td><input type="checkbox" value="--><?//echo $detail[$i]['order_id']?><!--" name="nid[]" class="" ></td>-->
          <td><? echo $i+1+$plate['page_list_num']*($nowpageid-1) ?></td>
          <!-- <td>

    <div class="icon" style="background-image: url('/uploadfiles/uf<?echo $site['mid']?>/<?echo $detail[$i]['icon']?>')"></div>


</td> -->
          <td><? echo $detail[$i]['name']?></td>
          <td><? echo $detail[$i]['model']?></td>
          <td>
		  	<?
			if($category){
				foreach($category as $val){

					if($val['nid'] == $detail[$i]['cat_id']){
						echo $val['name'];
					}
				}
			}
		?>
          </td>
          <td><? echo $detail[$i]['price']?></td>


<!--          <td>--><?// echo $detail[$i]['publish'] == 1 ? '显示' : '隐藏'?><!--</td>-->

          <td>
              <button type="button" class="menu_<?php echo $detail[$i]['nid'];?> layui-btn layui-btn-sm <? echo $detail[$i]['publish'] == 1 ? '' : 'layui-btn-danger'?>"
                      onclick="update_status(<?php echo $detail[$i]['nid'];?>)" >
                  <? echo $detail[$i]['publish'] == 1 ? '显示' : '隐藏'?>
              </button>
          </td>
          <td>
<!--              // TODO 后期再统计这单个产品的销售情况。-->
              <a href="detail-statistic.php?nav-itemed=product&nid=<? echo $detail[$i]['nid']?>&nowpageid=<?echo $nowpageid?>" class="layui-btn layui-btn-sm " >
                  <i class="fa fa-eye" aria-hidden="true"></i>详情
              </a>
              <a href="detail-edit.php?nav-itemed=product&nid=<? echo $detail[$i]['nid']?>&nowpageid=<?echo $nowpageid?>&now_extender=<?echo $system_part?>" class="layui-btn layui-btn-sm " >
                  <i class="layui-icon">&#xe642;</i>修改
              </a>

              <a href="javascript:void(0)" onclick="deleter(<?php echo $detail[$i]['nid']?>,'delete')"
                 class="delete layui-btn  layui-btn-sm" > <i class="layui-icon">&#xe640;</i>删除
              </a>

  		  </td>
    </tr>
  <?php

}
?>


  </tbody>
</table>






</div>



    <div class="list-box-function"
        <? if ($detailnum == 0) {
            echo "style" . "='display:none'";
        } ?>
        >

        <?php include 'module/page_numbers.php'; ?>

    </div>
</div>


<!--list-box end-->
</div>

<!--content端點01-->
</div>
<!--maincontent端點01-->
<br class="clearfloat"/>
</div>
<!--container端點01-->
</div>


<script type="text/javascript">
    function update_status(product_id){

        now_edit_status = $('.menu_'+product_id).html();
        var s = now_edit_status.replace(/\s+/g,"")  == '显示' ? 0 : 1;


        $.ajax({
            type:"POST",
            url:"ajax_controller.php?act=update_status",
            dateType:"json",
            data:{"status":s,'product_id':product_id},
            dataType:"json",

            success:
                function(data){
                    layer.msg(data.message);

                    if(data.error == 0){

                        $('.menu_'+product_id).html(s == 1 ? '显示' : '隐藏')
                        if(s == 1){
                            $('.menu_'+product_id).removeClass("layui-btn-danger");
                        }else{
                            $('.menu_'+product_id).addClass("layui-btn-danger")
                        }

                    }


                    //layer.closeAll();

                }
        })

    }


    //全选
    $("#quanxuan").click(function(){
        $("input[name='nid[]']").prop("checked",true);
        form.render('checkbox');
        // $("#shanchu").removeClass("layui-btn-disabled");
        // $("#shanchu").removeAttr("disabled")
    })

    //不选
    $("#buxuan").click(function(){
        $("input[name='nid[]']").prop("checked",false);
        form.render("checkbox");
        // $("#shanchu").addClass("layui-btn-disabled");
        // $("#shanchu").attr("disabled","disabled")
    })
</script>





<!--删除box-->
<?php include '../../../common/module/deletebar.php'; ?>
<!--删除box end-->

<?php include ROOT_PATH_ . "/controller/common/module/footer.php"; ?> </body>
</html>
